import { PageTmpItem } from './pageTmpItem';
import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
@Define.Table({ TableName: "page" })
export class Page extends EntityObjectType<Page>{
    @Define.PrimaryKey({
        DataLength: 32
    })
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    name: string;

    @Define.Column({
        DataType: Define.DataType.BOOL,
    })
    isDisable: boolean;

    /**
     * 页面唯一可读Id
     *
     * @type {string}
     * @memberof Page
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    viewId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        IsIndex: true,
    })
    flowNodeId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    type: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT,
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT,
    })
    updateTime: number;

    /**
     * 页面布局类型
     *
     * @type {string}
     * @memberof Page
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    layout: string;

    /**
     * 是否是表单页面
     * 
     * @type {boolean}
     * @memberof Page
     */
    @Define.Column({
        DataType: Define.DataType.BOOL,
    })
    isForm: boolean;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    permitId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    permitName: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    permitGroupName: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    submitUrl: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    refPageId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    orgId: string;

    canBack: boolean;

    @Define.Column({
        DataType: Define.DataType.JSON,
    })
    extends: PageExtends;

    @Define.Mapping({
        Mapping: 'PageTmpItem',
        MappingKey: 'pageId'
    })
    pageTmpItems: PageTmpItem[] = [];
}

export const PageType = {
    NodePage: 'nodePage',
    LoginPage: 'loginPage',
    NormalPage: 'normalPage'
}

export interface PageExtends {

}